﻿Imports 坐标转换类
Imports 坐标转换类.CoordTrans

Public Class Form1
    'Dim CT As New CoordTrans

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        grd.Rows.Add(9)

        Dim pointNo As Integer
        pointNo = grd.RowCount - 1
        For i = 0 To pointNo / 3 - 1 Step 1
            For j = 0 To 2 Step 1
                grd.Rows(i * 3 + j).Cells(0).Value = 50 + i * 150 / 3
                grd.Rows(i * 3 + j).Cells(1).Value = 50 + j * 50
            Next
        Next
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim mark1, mark2 As PointF
        Dim Cam1_P1, Cam1_P2 As PointF  '已经是实际坐标点


        mark1.X = Mark1_X.Value
        mark1.Y = Mark1_Y.Value
        mark2.X = Mark2_X.Value
        mark2.Y = Mark2_Y.Value

        Cam1_P1.X = Cam1_P1_X.Value
        Cam1_P1.Y = Cam1_P1_Y.Value
        Cam1_P2.X = Cam1_P2_X.Value
        Cam1_P2.Y = Cam1_P2_Y.Value

        Dim X, Y, Angle As Single
        X = (Cam1_P1.X + Cam1_P2.X) / 2
        Y = (Cam1_P1.Y + Cam1_P2.Y) / 2
        Angle = get_point_angle(mark1, mark2)
        Angle = get_point_angle(Cam1_P1, Cam1_P2) - Angle

        Dim g, h As Single
        g = (mark1.X + mark2.X) / 2
        h = (mark1.Y + mark2.Y) / 2


        Dim P, P1 As Drawing.PointF
        Dim pointNo As Integer
        pointNo = grd.RowCount - 1
        For i = 0 To pointNo - 1
            P1.X = grd.Rows(i).Cells(0).Value - g
            P1.Y = grd.Rows(i).Cells(1).Value - h
            P = P1toP_Transform(X, Y, Angle, P1)
            grd.Rows(i).Cells(2).Value = P.X
            grd.Rows(i).Cells(3).Value = P.Y
        Next

    End Sub





End Class
